package exercise01;

public class NewThread implements Runnable{
    private int ticket = 1000;
    @Override
    public void run() {
        while (true){
            synchronized (NewThread.class){
                if (ticket == 0){
                    break;
                }else{
                    try {
                        Thread.sleep(3);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    ticket--;
                    System.out.println(Thread.currentThread().getName()+" 还剩余："+ticket+"张票");
                }
            }
        }
    }
}
